
global d = "`1'"
do ${d}code/macrosim/simulation_config.do "`1'"

log using ${log_dir}/build_inputs.log, replace name(build_inputs)

*builds the inputs for the macrosimulation
*reshapes the dataset into a firm year country division (i.e. auto95 and pauto95) level
include ${d}code/macrosim/build_BvD_year_div_data.do

*rebuild inventorcounts for the weights that assign patents to countrystocks
if "`2'" == "yes" { 
    include ${d}code/macrosim/build_bvd_year_inventor_counts.do
}


*make weights resulting from those counts
include ${d}code/macrosim/build_weights_divnearestsep.do

*reformats the weights that distribute the spillovers back to the firms to work with the simulation
include ${d}code/macrosim/build_weights_pre.do 

*adjust for companies outside the sample
include ${d}code/macrosim/build_outsample_multiplier.do

*adjust the multiplier fo extreme cases
include ${d}code/macrosim/trunctuate_outsample_multiplier.do


cap log close build_inputs